/**
 * Copyright &copy; 2020 <a href="https://github.com/somowhere/exam-system">exam-system</a> All rights reserved.
 */
package com.shanhesoft.java.modules.exam.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shanhesoft.java.common.core.vo.PageModel;
import com.shanhesoft.java.common.persistence.service.impl.DataServiceImpl;
import com.shanhesoft.java.modules.exam.domain.TVTrainComments;
import com.shanhesoft.java.modules.exam.domain.dto.TVTrainCommentsDto;
import com.shanhesoft.java.modules.exam.domain.vo.TVTrainCommentsVo;
import com.shanhesoft.java.modules.exam.repository.TVTrainCommentsRepository;
import com.shanhesoft.java.modules.exam.service.TVTrainCommentsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 实验评论ServiceImpl 实验评论
 * @author superadmin
 * @version 2021-01-26 15:25:22
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class TVTrainCommentsServiceImpl extends DataServiceImpl<TVTrainCommentsRepository, TVTrainComments, TVTrainCommentsDto, String> implements TVTrainCommentsService{
	@Override
	public void saveOrUpdate(TVTrainCommentsDto tVTrainCommentsDto) {
														super.saveOrUpdate(tVTrainCommentsDto);
	}

	/**
	 * 按楼主评论分页
	 * @param pm
	 * @param wrapper
	 * @return
	 */
	@Override
	public IPage<TVTrainCommentsVo> findPage(PageModel pm, QueryWrapper wrapper) {
		IPage<TVTrainCommentsVo> page = repository.findCommentsByVid(pm, wrapper);
//		for(TVTrainCommentsVo vo : page.getRecords()) {
//			QueryWrapper<TVTrainComments> childWrapper = new QueryWrapper<TVTrainComments>();
//			childWrapper.eq("parent_id", vo.getId());
//			childWrapper.orderByAsc("created_date");
//			List<TVTrainCommentsVo> childList = findList(childWrapper);
//
//		}
		return page;
	}

	/**
	 * 根据顶楼ID查询对应回复
	 * @param wrapper
	 * @return
	 */
//	@Override
//	public List<TVTrainCommentsVo> findList(QueryWrapper wrapper) {
//		return repository.findCommentsByVid(wrapper);
//	}
}
